// DON'T USE : tuning in progress
// to do:
//    revise cursor modification
//    multiple selected item for drag
//    (restablish correct zIndex in direct move)
//    cleanup code
//	  mouse down handler linked to object to move
// old todo :
//    OK cohabitation DD et RS / same div
//    OK test drop
//    OK? test callback routines
//	  FIXED bug if lift in parent div to move, (to revise?)




rialto.widgetBehavior.DragAndDrop_cstes = {
	zIndexMovingOHtml      : 1000000,
	zIndexInfoFrame		   : 1000001
}
rialto.widgetBehavior.DragAndDrop_defaults = {
	ghost_opacity      : 0.5,
	markSelect_opacity : 0.5
}

// event's handlers for DragAndDrop
rialto.widgetBehavior.DragAndDropMouseDownHandler= function (e){
//-----------------------------------------------

    if (!e) var e = window.event;

    // restriction ? la zone sensible au DD ? l'elt Html enregistrant l evt
    var oSourceEvt = e.target ? e.target: e.srcElement;
    // mod pour Moz si clic non direct sur elt avec attribut .dragAndDrop mais fils
    var cibl = rialto.widgetBehavior.DDtargetOrTargetChild(oSourceEvt); // 
    if (!cibl){
       //traceExec( 'hors cible',73);
       return ;
    }
    else{
       /* traceExec( 'dans cible',73); */
       oSourceEvt = cibl;  // mod pour Moz si clic non direct sur elt avec attribut .dragAndDrop mais fils
    }

     var oHtml = oSourceEvt;

    // object with DD specifications
    var oSpecs = oHtml.refObjSpecs;
    //--- zone d'exclusion / dragAndDrop'
    /* traceExec('DD MD oSpecs.specs.sensitiveEdgeWidth= '+oSpecs.specs.sensitiveEdgeWidth,75); */
    var direction =  DirDeplact(oHtml,e
    							,_rum.$getHeight(oHtml) // pixHeight(oHtml)
    							,_rum.$getWidth(oHtml) //pixWidth(oHtml)
                               , oSpecs.specs.sensitiveEdgeWidth,true //oHtml.margeSensible,true
                               ,oSpecs.movingLimits.orientation);

    /* traceExec('DD MD direction= DirDeplact= '+direction,75); */
   if (! direction)  {
       return;
   }

	// RS in progress ?
	if (	(oHtml.behavior['RS'])
		&&	(oHtml.behavior['RS'].isRunning))
			return;
	else
		oHtml.behavior['DD'].isRunning = true;

    //--- load limits if dynamics
    if (oSpecs.specs.bDynamicsMovingLimits)
       oSpecs.loadLimitsDyn();
       
    // object to move in fine and this parent (by default = reference for limits)
    var oHtmlToMove =  oSpecs.specs.oHtmlToMove;    
    var oHtmlParentRef =  oHtmlToMove.parentNode;
    var boundOHtmlRef = oSpecs.movingLimits.oHtmlRef;

	//--- visual witness of selection for DD
    if (oSpecs.specs.bSelectMark){
        var maskSelect = document.createElement('DIV');
        maskSelect.id = 'maskSelectDD_unique';
        maskSelect.className     = 'maskSelectDD';
        maskSelect.style.top     = - _rum.$$getBorderTopWidth(oHtmlToMove);
        maskSelect.style.left    = - _rum.$$getBorderLeftWidth(oHtmlToMove);
        maskSelect.style.width   = oHtmlToMove.offsetWidth;    // pixWidth(oHtmlToMove);
        maskSelect.style.height  = oHtmlToMove.offsetHeight;   // pixHeight(oHtmlToMove);
 		rialto.effect.opacity(maskSelect,0.5);
//    	maskSelect.style.filter  = "alpha(opacity:50)";
//        maskSelect.style.opacity = 0.5;
        oHtmlToMove.appendChild(maskSelect);
    }

	var parentOHtmlToMove;
    var nextSiblOHtmlToMove;
    var isMovingOHtmlInDoct = true;
	  
      // # 1 position of oHtmlToMove in viewPort
      var topLeftDivToMoveInVP	= _rum.$divTopLeftInViewPort(oHtmlToMove);
	  var topDivToMoveInVP  	= topLeftDivToMoveInVP.top;
	  var leftDivToMoveInVP 	= topLeftDivToMoveInVP.left;
traceExec('topDivToMoveInVP  	= '+topLeftDivToMoveInVP.top+
	      ' leftDivToMoveInVP 	= '+topLeftDivToMoveInVP.left,73);

	  // # 2 position of cursor in viewPort
	  var topLeftEvtInVP  = _rum.$eventTopLeftInViewPort(e);
	  var topEvtInVP  	  = topLeftEvtInVP.top;
	  var leftEvtInVP 	  = topLeftEvtInVP.left;

	  // delta between pos initial of oHtmlToMove and icon position 
	  shiftTopForIcon  = 0;
	  shiftLeftForIcon = 0;

	  // new # 1 = # 2 oHtmlToMove considered as in cursor position 
	  if (		(oSpecs.specs.ghost.bIcone) 
	  	  &&	(!oSpecs.specs.magneticsGrid)) {
	  	  shiftTopForIcon  = (oSpecs.movingLimits.orientation == 'h') ? 0 : topEvtInVP - topDivToMoveInVP; 
	  	  shiftLeftForIcon = (oSpecs.movingLimits.orientation == 'v') ? 0 : leftEvtInVP - leftDivToMoveInVP; 
	  	  topDivToMoveInVP  = topEvtInVP;
	  	  leftDivToMoveInVP = leftEvtInVP;
	  }
	  // # 3 internal position (= after border) of parent's oHtmlToMove in view port
	  var iTopLeftBoundDivToMoveInVP = _rum.$divInternalTopLeftInViewPort(boundOHtmlRef);
	  
	  var iTopBoundDivToMoveInVP     = iTopLeftBoundDivToMoveInVP.top;
	  var iLeftBoundDivToMoveInVP    = iTopLeftBoundDivToMoveInVP.left;
	  
	  
	  var iTopLeftParDivToMoveInVP = _rum.$divInternalTopLeftInViewPort(oHtmlParentRef);
	  
	  var iTopParDivToMoveInVP     = iTopLeftParDivToMoveInVP.top;
	  var iLeftParDivToMoveInVP    = iTopLeftParDivToMoveInVP.left;

	  // # 4 = (# 2 - # 1) delta between topLeft of oHtmlToMove and cursor position
	  var deltaTopCursOHtmlToMove  = topEvtInVP  - topDivToMoveInVP;
	  var deltaLeftCursOHtmlToMove = leftEvtInVP - leftDivToMoveInVP;

    topMovingDiv  = topDivToMoveInVP;     
    leftMovingDiv = leftDivToMoveInVP; 

	var isMovingOHtmlRelPos = false;
	var	 initTopInRel;
	var	 initLeftInRel;
	var topInNaturalFlow, leftInNaturalFlow;

	//--- mobile object during drag is a ghost of object to move
	// to try : oSpecs.specs.ghost.asChild = true;
    if (	oSpecs.specs.ghost
    	&&  !oSpecs.specs.ghost.asChild){
      var ghostFrame = document.getElementById('singleGhostFrame');
      if (ghostFrame == null) {
        ghostFrame = document.createElement('DIV');
        ghostFrame.id = 'singleGhostFrame';
      }
	  ghostFrame.style.width = '';   //reinit for css application 
	  ghostFrame.style.height = '';    
      ghostFrame.className = 'ghostDD_' + oSpecs.specs.ghost.aspect; //'cadreDeplactFenetreMobile';

 	  rialto.effect.opacity(ghostFrame,
 	  						rialto.widgetBehavior.DragAndDrop_defaults.ghost_opacity
 	  						);
      document.body.appendChild(ghostFrame);
 //to try     ghostFrame.style.zIndex 		= rialto.widgetBehavior.DragAndDrop_cstes.zIndexMovingOHtml; //100000;
      
      

	  // set ghost in view port
      ghostFrame.style.top	=  topMovingDiv;   								  				  	
      ghostFrame.style.left	=  leftMovingDiv;
	        
      // ghost is a copy of object to move but not a simple image
      // over the cursor      
	  if (!oSpecs.specs.ghost.bIcone) {
	  
	      _rum.$setSizeConformW3C(ghostFrame, oHtmlToMove);	    

		  // a revoir pour harmoniser IE et Fx si bordures top-bottom
		  if (oSpecs.specs.ghost.height)
		  	  ghostFrame.style.height = eval(oSpecs.specs.ghost.height);   
	  } 	  
	  if (oSpecs.specs.ghost.top)
	  	  ghostFrame.style.top = eval(oSpecs.specs.ghost.top);   
	  
	  // else aspect , width and height in css	
	  
      ghostFrame.style.display  = 'block';
      
	  /* traceExec('MD ghostFrame.className= '+ghostFrame.className,2); */			
	  /* traceExec('ghostFrame.style.top= '   +ghostFrame.style.top,2); */
	  /* traceExec('ghostFrame.style.left= '   +ghostFrame.style.left,2); */
	  /* traceExec('ghostFrame.style.width= '   +ghostFrame.style.width,2); */
	  /* traceExec('ghostFrame.style.height= '   +ghostFrame.style.height,2); */

      var movingOHtml = ghostFrame;
      movingOHtml.refObjSpecs = oSpecs;  // pour Moz en mode fantome
	}
	
	// essentially  for splitter with part masked
	else
	if (	oSpecs.specs.ghost
    	&&  oSpecs.specs.ghost.asChild){
    	
     
      var ghostFrame = document.getElementById('singleGhostFrame');
      if (ghostFrame == null) {
        ghostFrame = document.createElement('DIV');
        ghostFrame.id = 'singleGhostFrame';
      }
      ghostFrame.style.top = oHtmlToMove.offsetTop;
      ghostFrame.style.left = oHtmlToMove.offsetLeft;
      
	  ghostFrame.style.width = '';   //reinit for css application 
	  ghostFrame.style.height = '';    
      ghostFrame.className = 'ghostDD_' + oSpecs.specs.ghost.aspect; //'cadreDeplactFenetreMobile';

 	  rialto.effect.opacity(ghostFrame,
 	  						rialto.widgetBehavior.DragAndDrop_defaults.ghost_opacity
 	  						);
	  oHtmlToMove.parentNode.appendChild(ghostFrame);

      
      // ghost is a copy of object to move but not a simple image
      // over the cursor      
	  if (!oSpecs.specs.ghost.bIcone) {
	  
	      _rum.$setSizeConformW3C(ghostFrame, oHtmlToMove);	    

		  // a revoir pour harmoniser IE et Fx si bordures top-bottom
		  if (oSpecs.specs.ghost.height)
		  	  ghostFrame.style.height = eval(oSpecs.specs.ghost.height);   
	  } 	  
	  ghostFrame.style.zIndex 		= rialto.widgetBehavior.DragAndDrop_cstes.zIndexMovingOHtml; //100000;
	  ghostFrame.style.display = 'block';

      var movingOHtml = ghostFrame;
      movingOHtml.refObjSpecs = oSpecs;  // pour Moz en mode fantome
//--
		 	 isMovingOHtmlInDoct = false;	

 			 isMovingOHtmlRelPos = (movingOHtml.style.position == 'relative'); //true;
			 initTopInRel = parseInt(_rum.$getStyle(movingOHtml,'top'));
			 initLeftInRel = parseInt(_rum.$getStyle(movingOHtml,'left'));
			 topInNaturalFlow  = movingOHtml.offsetTop - initTopInRel;
			 leftInNaturalFlow  = movingOHtml.offsetLeft - initLeftInRel;
             topMovingDiv  = (movingOHtml.style.position == 'relative') ?
             							initTopInRel
             						: 	movingOHtml.offsetTop; 
             leftMovingDiv  = (movingOHtml.style.position == 'relative') ?
             							initLeftInRel
             						: 	movingOHtml.offsetLeft; 
    }
	
	//--- direct drag of object to move
    else{
        var movingOHtml, top, left;
         
         movingOHtml = oHtmlToMove;
         
		 // DD without targets 
		 /* traceExec('MD oSpecs.specs.dropTarget= '+oSpecs.specs.dropTargets,79); */
//		 if (!oSpecs.specs.dropTargets) { // remove this restriction ?	
		 	 isMovingOHtmlInDoct = false;	

 			 isMovingOHtmlRelPos = (movingOHtml.style.position == 'relative'); //true;
			 initTopInRel = parseInt(_rum.$getStyle(movingOHtml,'top'));
			 initLeftInRel = parseInt(_rum.$getStyle(movingOHtml,'left'));
//			 initTopInRel = parseInt(movingOHtml.style.top);
//			 initLeftInRel = parseInt(movingOHtml.style.left);
			 topInNaturalFlow  = movingOHtml.offsetTop - initTopInRel;
			 leftInNaturalFlow  = movingOHtml.offsetLeft - initLeftInRel;
             topMovingDiv  = (movingOHtml.style.position == 'relative') ?
             							initTopInRel
             						: 	movingOHtml.offsetTop; 
             leftMovingDiv  = (movingOHtml.style.position == 'relative') ?
             							initLeftInRel
             						: 	movingOHtml.offsetLeft; 
             						
/*
             topMovingDiv = movingOHtml.offsetTop;
             leftMovingDiv = movingOHtml.offsetLeft;
*/
/*
         }
		 // DD with targets (Missile)
		 // move missile to document  / zIndex
         else {
         // to revise :
        */ /* traceExec('MD movingOHtml placed in document',79); *//*
         	parentOHtmlToMove = movingOHtml.parentNode;
         	nextSiblOHtmlToMove = movingOHtml.nextSibling;
         	document.body.appendChild(movingOHtml);
         }
*/         
         
         
 	}
 	
	  var shiftRelToAbsTop  = (isMovingOHtmlInDoct)  ? 0:iTopLeftParDivToMoveInVP.top  ;
	  var shiftRelToAbsLeft = (isMovingOHtmlInDoct)  ? 0:iTopLeftParDivToMoveInVP.left ;
	  var shiftAbsToRelTop  = (isMovingOHtmlInDoct) ? -iTopLeftParDivToMoveInVP.top  : 0;
	  var shiftAbsToRelLeft = (isMovingOHtmlInDoct) ? -iTopLeftParDivToMoveInVP.left : 0;
	  
 	// rect limit for moving : compute dimensions and  position relative to oHtmlToMove's parent
	if (oSpecs.movingLimits.bRectLim) {
		var dLimLeft = dLimTop = dLimRight = dLimBottom = 0;
		
		if (oSpecs.movingLimits.orientation == 'h') {
			dLimTop 	= 	iTopParDivToMoveInVP - iTopBoundDivToMoveInVP
						  +	oHtmlToMove.offsetTop;
						  //+	parseInt(oHtmlToMove.style.top);
			dLimBottom  = dLimTop + oHtmlToMove.offsetHeight;
		}
		else {
			dLimTop 	= oSpecs.movingLimits.rectLim.top;
			dLimBottom 	= oSpecs.movingLimits.rectLim.bottom;
		}
		if (oSpecs.movingLimits.orientation == 'v'){
			dLimLeft 	= 	oHtmlToMove.offsetLeft // parseInt(oHtmlToMove.style.left)
						  +	iLeftParDivToMoveInVP - iLeftBoundDivToMoveInVP;
			dLimRight	= dLimLeft + oHtmlToMove.offsetWidth;
//			dLimLeft 	= parseInt(oHtmlToMove.style.left);
//			dLimRight	= parseInt(oHtmlToMove.style.left) + oHtmlToMove.offsetWidth;
		}
		else {
			dLimLeft 	= oSpecs.movingLimits.rectLim.left;
			dLimRight	= oSpecs.movingLimits.rectLim.right;
		}		
		var gheight =   (dLimBottom - dLimTop);
		var gwidth  = 	(dLimRight  - dLimLeft);
		
		// magnetic grid : nb of columns, rows
		if (oSpecs.specs.magneticsGrid) {
			oSpecs.specs.magneticsGrid.nbHorizontalLines =
				parseInt(	(gheight - parseInt(oHtmlToMove.offsetHeight))
						  / oSpecs.specs.magneticsGrid.heightRow) +1;
			oSpecs.specs.magneticsGrid.nbVerticalLines = 
				parseInt(	(gwidth - parseInt(oHtmlToMove.offsetWidth))
						  / oSpecs.specs.magneticsGrid.widthCol) +1;
		}						  
	}

	// display of limits
	if (oSpecs.movingLimits.isWithLimitsDisplayed) {
		var limRect = document.createElement('DIV');
		limRect.style.width  = gwidth;
		limRect.style.height = gheight;
		limRect.className    = 'line dashed greenBorder';
		
		document.body.appendChild(limRect);		
		_rum.$setWidthConformW3C(limRect);
		
		var revisedHeight = _rum.$setHeightConformW3C(limRect);
		var IEBorder      = revisedHeight - gheight;
		var gridEdgeWidth = _rum.$$getBorderTopWidth(limRect); //or parseInt(_rum.$getStyle(limRect,'borderTopWidth'));

        limRect.style.top	 =  iTopBoundDivToMoveInVP - gridEdgeWidth  + dLimTop;   								  				  	
        limRect.style.left   =  iLeftBoundDivToMoveInVP - gridEdgeWidth + dLimLeft;
		
		
		// display magnetic grid
		if (	oSpecs.specs.magneticsGrid
			&&  oSpecs.specs.magneticsGrid.bDisplayed) {
		
				
			traceExec('MD grid dLimTop= '+dLimTop+' dLimLeft= '+dLimLeft
						+' gwidth = '+gwidth+' gheight= '+gheight,2);
			gtop =  - gridEdgeWidth;
			for (var i=0; i < oSpecs.specs.magneticsGrid.nbHorizontalLines ; i++) {
				line = document.createElement('DIV');
				line.className = 'line horizontal redBorder';
				line.style.top      = gtop;
				line.style.left 	= 0;
				line.style.width 	= parseInt(limRect.style.width) - (IEBorder);
				
				line.style.height = 0;
				// really necesserary for IU only :
/**/			line.style.clip = 'rect(0,'
					+ parseInt(line.style.width)+'px,'
					+ gridEdgeWidth
					+ ',0)';		
/**/
				gtop = gtop + oSpecs.specs.magneticsGrid.heightRow;
				
				limRect.appendChild(line);
			}
			gleft = - gridEdgeWidth;
            for (var i=0; i < oSpecs.specs.magneticsGrid.nbVerticalLines ; i++) {				
				lineV = document.createElement('DIV');
				lineV.className 	= 'line vertical aquamarineBorder';
				lineV.style.left 	= gleft;
				lineV.style.top 	= 0; /* traceExec('parseInt(limRect.style.height)= '+parseInt(limRect.style.height),2); */
				lineV.style.height 	= parseInt(limRect.style.height) - (IEBorder);

				lineV.style.clip = 'rect(0,'
					+ gridEdgeWidth +','+
					+ parseInt(lineV.style.height)+'px'
					+ ',0)';		

				gleft = gleft + oSpecs.specs.magneticsGrid.widthCol;
				limRect.appendChild(lineV);
			}
			 
		}
	
	} // isWithLimitsDisplayed

	// display infos /movement
	if (oSpecs.isWithMovingInfo) {
	    var infoFrame = document.createElement('DIV');
	    infoFrame.className = "DDinfoFrame";
	    infoFrame.topShift  = 10;
	    infoFrame.leftShift = 20;

		infoFrame.topShiftI    = topEvtInVP; 
		infoFrame.leftShiftI   = leftEvtInVP; 
		
		infoFrame.style.top    = infoFrame.topShiftI  + infoFrame.topShift;
		infoFrame.style.left   = infoFrame.leftShiftI + infoFrame.leftShift;

		infoFrame.style.filter  = "alpha(opacity:50)";
	    infoFrame.style.opacity = 0.5;
	    infoFrame.style.zIndex 	= rialto.widgetBehavior.DragAndDrop_cstes.zIndexInfoFrame;  //100001;
	    infoFrame.isWithMovingInParentInfo = oSpecs.isWithMovingInParentInfo;
	    if (oSpecs.isWithMovingInParentInfo)
		    infoFrame.innerHTML 	= 	(parseInt(movingOHtml.style.top) + shiftAbsToRelTop) + ","  +
		    					    	(parseInt(movingOHtml.style.left)+ shiftAbsToRelLeft) ;
		else 
		    infoFrame.innerHTML 	= 	(parseInt(movingOHtml.style.top) + shiftRelToAbsTop) + ","  +
		    					    	(parseInt(movingOHtml.style.left) + shiftRelToAbsLeft);
	    					    
	    document.body.appendChild(infoFrame);
	}
traceExec('isMovingOHtmlRelPos	: '+isMovingOHtmlRelPos+
	  ' initTopInRel			: '+initTopInRel+
	  ' initLeftInRel			: '+initLeftInRel,2);

	var dTopParentToBoundRef ,dLeftParentToBoundRef ;
	  if (oHtmlParentRef == boundOHtmlRef ) {
			dTopParentToBoundRef = 0;
			dLeftParentToBoundRef = 0;
		}
		else {
			dTopParentToBoundRef  = iTopLeftBoundDivToMoveInVP.top - iTopLeftParDivToMoveInVP.top;
			dLeftParentToBoundRef = iTopLeftBoundDivToMoveInVP.left - iTopLeftParDivToMoveInVP.left;
		}
        
	top = parseInt(movingOHtml.style.top);
	left = parseInt(movingOHtml.style.left);
						  
 	// update current drag object managed by _DDMgr
    _DDMgr.currDrag = {
    	oThis          : oSpecs,
        oSource        : oHtml,
        ghost          : oSpecs.specs.ghost,
 		maskSelect 	   : (oSpecs.specs.bSelectMark? 
 							maskSelect : null),
        
        movingOHtml		: movingOHtml,
        oHtmlToMove		: oHtmlToMove,


        bMUpAction      : oSpecs.specs.bMUpAction,
/*
        tx             : e.clientX - left, // decalage du curseur ds l'objet en deplact
        ty             : e.clientY - top,
*/        
        
//--------------
 	  isMovingOHtmlRelPos	: isMovingOHtmlRelPos,
	  topInNaturalFlow		: topInNaturalFlow,
	  leftInNaturalFlow		: leftInNaturalFlow,
	  isMovingOHtmlInDoct	: isMovingOHtmlInDoct,
	  
	  initialTop			: initTopInRel,
	  initialLeft			: initLeftInRel,
	  
      // # 1 position of oHtmlToMove in viewPort
	  topDivToMoveInVP		: topDivToMoveInVP,
	  leftDivToMoveInVP 	: leftDivToMoveInVP,

	  // # 2 initial (MD) position of cursor, in viewPort
	  topEvtInVP  	  		: topEvtInVP,
	  leftEvtInVP			: leftEvtInVP, 	  

	  
	  // # 3 internal position (= after border) of parent's oHtmlToMove in view port
	  iTopBoundDivToMoveInVP	: iTopBoundDivToMoveInVP,
	  iLeftBoundDivToMoveInVP	: iLeftBoundDivToMoveInVP,
	  shiftAbsToRelTop		: shiftAbsToRelTop,
	  shiftAbsToRelLeft		: shiftAbsToRelLeft,
	  shiftRelToAbsTop		: shiftRelToAbsTop,
	  shiftRelToAbsLeft		: shiftRelToAbsLeft,
	  
	  // # 4 = (# 2 - # 1) delta between topLeft of oHtmlToMove and cursor position
	  deltaTopCursOHtmlToMove	: deltaTopCursOHtmlToMove,
	  deltaLeftCursOHtmlToMove  : deltaLeftCursOHtmlToMove,
	  // to revise (for pb with splitter & eventPos) :
	  eventTopLeftInDiv			: {  top  : deltaTopCursOHtmlToMove
	  							   , left : deltaLeftCursOHtmlToMove},
	  
	  // initial position (MD) of moving div, in VP
      topMovingDiv				: topMovingDiv,
      leftMovingDiv 			: leftMovingDiv,


	  totDeltaMoveTop 			: 0,
	  totDeltaMoveLeft 			: 0,

//--------------        
	  dTopParentToBoundRef 		: dTopParentToBoundRef,
	  dLeftParentToBoundRef 	: dLeftParentToBoundRef,

/*        
        
        // positions initiales de l'objet a deplacer au mouse down.  (pour synchro)
        posInitObjADeplacer : {top : pixTop  (oHtmlToMove),
                               left: pixLeft (oHtmlToMove)} ,
        // position initiales au mouse down
     	parentOHtmlToMove : parentOHtmlToMove,
     	nextSiblOHtmlToMove : nextSiblOHtmlToMove,

        topI           : top,  //= top obj a deplacer = top obj en deplact= top fantome sauf icone
        leftI          :left,
        
        dTopI		   : internalTopLeft.top,  //decalage entre position icone au MD  et topI leftI
        dLeftI         : internalTopLeft.left, 
*/
        // positions au fur et a mesure des mouse move (initialement = position au )mouse down). (pour synchro)
        prevTop        : top,
        prevLeft       : left,
        // temoin d un deplacement de la souris (= mouse move effectif)
        mvtEffectif    : false,
        // temoin (s'il y a des cibles definies) d'un bon positionnement / cibles
        cibleOk        : false,
        
        svgZIndex      : movingOHtml.style.zIndex|| 0, // to revise more complex : the zIndex must be computed if no

//		isLimitsDisplayed : oSpecs.movingLimits.isLimitsDisplayed,
		oHtmlParentRef : oHtmlParentRef,
		boundOHtmlRef	: boundOHtmlRef,
		oHtmlLimitsRect : limRect,
		oHtmlInfoFrame : infoFrame
    };
 	
    
///* traceExec('infoFrame.isWithMovingInParentInfo   = '+infoFrame.isWithMovingInParentInfo,2); */
/* traceExec('MD attr of _DDMgr.currDrag :',2); */
/*
   for (attr in _DDMgr.currDrag) {
   		if ( (typeof _DDMgr.currDrag[attr]) != 'object')
    		// traceExec(attr + '= '+_DDMgr.currDrag[attr],2); 
    }	
*/    	
//to try    _DDMgr.currDrag.oHtmlToMove.style.zIndex = rialto.widgetBehavior.DragAndDrop_cstes.zIndexMovingOHtml; //100000;
    _DDMgr.currDrag.movingOHtml.style.zIndex = rialto.widgetBehavior.DragAndDrop_cstes.zIndexMovingOHtml; //100000;

    if ( this.setCapture) {
       this.setCapture();
		//pour permettre par exemple ? la fenetre d etre activ?e par un Md ds barre Titre pour DD stopEvent(e);
       if (   (!oSpecs.specs.modCurs.avantDD)
           && (oSpecs.specs.modCurs.auClic)) {
          rialto.widgetBehavior.DDmodCursor(oHtml,direction,oSpecs.movingLimits.orientation,false);
       }
    }
    else {
       if (   (!oSpecs.specs.modCurs.avantDD)
           && (oSpecs.specs.modCurs.auClic)) {
            if (oSpecs.specs.ghost)
                 rialto.widgetBehavior.DDmodCursor(objetEnDeplact,direction,oSpecs.movingLimits.orientation,true);
            else
                 rialto.widgetBehavior.DDmodCursor(oHtml,direction,oSpecs.movingLimits.orientation,true);
       }
    }
    
    
    // essentiellement pour les pb issu du traitement centralis? sur obj doct pour FireFox
    var oThis = _DDMgr.currDrag.oThis;
    if (oThis.afterMD){
        oThis.afterMD();
    }
	//              stopEvent();
	
	
}

rialto.widgetBehavior.DragAndDropMouseMoveHandler = function (e){
//--------------------------------------------------------------
 // tester la sortie du navigateur pour realiser _DDMgr.currDrag = null juste avant ?
  if (!e) var e = window.event;

  var oHtml = e.target  ? e.target  
                        : e.srcElement;

  // DD not beginning
  //-------------------
  if (!_DDMgr.currDrag) {

    if (!oHtml.dragAndDrop) {
  
       // a revoir
      //necessaire si cette Div fille n'a pas de curseur explicitement d?fini pour ne pas se voir attribu? le curseur
      //de la Div (cible du DD) sous-jacente si l'on est deja pass? directement dessus
      //oHtml.style.cursor = "default";
       return;
    }

	/* supp prov
		    if (oHtml.oCiu['ReSize']  && oHtml.oCiu['ReSize'].dsChampMm){
		        oHtml.oCiu['ReSize'].dsChampMm = false;
		        return;
		    }
	*/
	//   oHtml.svgCursor = oHtml.style.cursor;
	
    // objet detenant les specs du DD
    var oSpecs = oHtml.refObjSpecs;

    if (oSpecs.specs.modCurs.avantDD){
/* traceExec('DD MM oSpecs.specs.sensitiveEdgeWidth= '+oSpecs.specs.sensitiveEdgeWidth,75); */
        var direction = DirDeplact(oHtml,e
    							,_rum.$getHeight(oHtml) // pixHeight(oHtml)
    							,_rum.$getWidth(oHtml) //pixWidth(oHtml)
                               , oSpecs.specs.sensitiveEdgeWidth, true
                               ,oSpecs.movingLimits.orientation);
/* traceExec('DD MM direction = DirDeplact= '+direction,75); */
        rialto.widgetBehavior.DDmodCursor(oHtml,direction,oSpecs.movingLimits.orientation,false);
/* traceExec('DD MM DDmodCursor oHtml.style.cursor = '+oHtml.style.cursor,75); */
    }
// 2 pb se telescopent :
//	RS masque RS / cursor
//  witness of margins  masque div DD et donc le cursor attach? ? cette div    
    /* traceExec('DD MM oHtml.dragAndDrop = '+oHtml.dragAndDrop,74); */

  }
              
  // DD in progress
  //---------------
  else {
    if (e.clientX >= 0 && e.clientY >= 0){

        var oMovingStyle = _DDMgr.currDrag.movingOHtml.style;
        
		/* traceExec('MM _DDMgr.currDrag.movingOHtml= '+_DDMgr.currDrag.movingOHtml.id,5); */                    
		/* traceExec('MM : _DDMgr.currDrag.movingOHtml.id ='+_DDMgr.currDrag.movingOHtml.id,1); */
		traceExec('MM : ' 
		+' top= '         +oMovingStyle.top
		+' left= '       +oMovingStyle.left
		+' width= '      +oMovingStyle.width
		+' height = '    +oMovingStyle.height
		+' backColor = ' +oMovingStyle.backgroundColor
		+' e.clientX = ' +e.clientX 
//		+' _DDMgr.currDrag.tx = '+_DDMgr.currDrag.tx
		,2);

        _DDMgr.currDrag.mvtEffectif = true;

        // position if no constraints 
        //---------------------------
//		var totDeltaMoveTop  = e.clientY - _DDMgr.currDrag.topEvtInVP;
//		var totDeltaMoveLeft = e.clientX - _DDMgr.currDrag.leftEvtInVP;

	    var nvEventTopLeft = _rum.$eventTopLeftInViewPort(e);
	    					//	,_DDMgr.currDrag.eventTopLeftInDiv);
/* traceExec('nvEventTopLeft.top= '+nvEventTopLeft.top+'nvEventTopLeft.left= '+nvEventTopLeft.left,73); */
/* traceExec('_DDMgr.currDrag.topEvtInVP= '+_DDMgr.currDrag.topEvtInVP+'_DDMgr.currDrag.leftEvtInVP= '+_DDMgr.currDrag.leftEvtInVP,73); */
		var totDeltaMoveTop  = nvEventTopLeft.top - _DDMgr.currDrag.topEvtInVP;
		var totDeltaMoveLeft = nvEventTopLeft.left - _DDMgr.currDrag.leftEvtInVP;
/* traceExec('totDeltaMoveTop = '+totDeltaMoveTop+'totDeltaMoveLeft = '+totDeltaMoveLeft ,73); */	
		
		newPos = {}; // 
		newPos.top =    _DDMgr.currDrag.topMovingDiv 				// initial position
					  +	totDeltaMoveTop;							// + total movement
					  
		newPos.left =   _DDMgr.currDrag.leftMovingDiv				// initial position
				 	  +	totDeltaMoveLeft ;							// + total movement	
/* traceExec('before constraints: newPos.top= '+newPos.top+ 'newPos.left= '+newPos.left,73); */
			
        // yet, apply constraints
        //-----------------------
        // objet detenant les specs du DD
        var oWithSpecs = _DDMgr.currDrag.oThis;
/*? r?tablir : pour test*/
		var dTopLeft = rialto.widgetBehavior.$$DDMM_AbsToRel();

        // #1 constraints / limit rect
        //---------------------------       
        if (oWithSpecs.movingLimits.bRectLim) {
            rialto.widgetBehavior.$$DDMM_applyConstraintsLimits(oWithSpecs, newPos, dTopLeft.top, dTopLeft.left);
        }

        
        // #2 constraints / magnetics grid
        //--------------------------------
        if (oWithSpecs.specs.magneticsGrid){
        
        	rialto.widgetBehavior.$$DDMM_applyConstraintsMagneticsGrid(oWithSpecs,newPos, dTopLeft.top, dTopLeft.left);
        }
		

        oMovingStyle.left = newPos.left;
        oMovingStyle.top  = newPos.top;
traceExec('apply newPos.top= '+newPos.top
			+ 'newPos.left= '+newPos.left,73);

        // #3 constraints / authorized targets
        //------------------------------------
        if (    (oWithSpecs.specs.dropTargets)
            &&  (!oWithSpecs.specs.cibleOk)) {  // ???? to revise
                
			rialto.widgetBehavior.$$DDMM_applyConstraintTargets(oWithSpecs);


            rialto.widgetBehavior.DDmodCursor(_DDMgr.currDrag.movingOHtml,oWithSpecs.movingLimits.orientation,_DDMgr.currDrag.orientation,_DDMgr.currDrag.cibleOk);
        } 
/* traceExec('DDMM _DDMgr.currDrag.cibleOk= '+_DDMgr.currDrag.cibleOk,77); */        
/* traceExec('nv left av synchro = '+oMovingStyle.left,1); */


		// record total/last move amplitude
		//---------------------------
		_DDMgr.currDrag.totDeltaMoveTop =   newPos.top 				     // new top    
					  					  - _DDMgr.currDrag.topMovingDiv     // initial top
		_DDMgr.currDrag.totDeltaMoveLeft =  newPos.left
										  - _DDMgr.currDrag.leftMovingDiv   // initial top

		
		// display info about moving 
		//--------------------------
		if (_DDMgr.currDrag.oHtmlInfoFrame) {

			rialto.widgetBehavior.$$DDMM_displayInfos(oMovingStyle,e,nvEventTopLeft);
	    }				

        // callBack routine for synchro
        //-----------------------------
        if (oWithSpecs.synchro)
            rialto.widgetBehavior.$$DDMM_CallBackSynchro (oWithSpecs);


        } //e.client

/* traceExec('end DDMM _DDMgr.currDrag.cibleOk= '+_DDMgr.currDrag.cibleOk,77); */        
  }  // DD en cours
              
 //please don't remove this comment :
 //remove stopEvent(e)/ DD elts in ContainerAutoScroll; revise if it's necessary in other context
 //stopEvent(e);
}
rialto.widgetBehavior.$$DDMM_AbsToRel = function () {
//========================================================
var dTop,dLeft;
/* traceExec('DDMM_AbsToRel begin',73); */
 // ghost moving
 // ghost with coordonnees / viewPort --> retablisst de ses coord / pere (= repere utilise pour limites)
 if (_DDMgr.currDrag.isMovingOHtmlInDoct){
	dTop = _DDMgr.currDrag.iTopBoundDivToMoveInVP;
	dLeft = _DDMgr.currDrag.iLeftBoundDivToMoveInVP;
 	/* traceExec('isMovingOHtmlInDoct = true; dTop= '+dTop+' dLeft= '+dLeft,73); */
 }
 // direct moving
 else {
 	// shift parent to Html's bound ref  
 	dTop  = _DDMgr.currDrag.dTopParentToBoundRef;
 	dLeft = _DDMgr.currDrag.dLeftParentToBoundRef;
 	/* traceExec('isMovingOHtmlInDoct = false; dTop= '+dTop+' dLeft= '+dLeft,73); */

    // relative pos for oHtmlToMove : shift initial position
 	if (_DDMgr.currDrag.isMovingOHtmlRelPos) {
		dTop  -=   
				_DDMgr.currDrag.topInNaturalFlow;
		dLeft -=   
				 _DDMgr.currDrag.leftInNaturalFlow;
//		dTop  =  - _DDMgr.currDrag.topInNaturalFlow;
//		dLeft =  - _DDMgr.currDrag.leftInNaturalFlow;
	 	/* traceExec('isMovingOHtmlRelPos = true; dTop= '+dTop+' dLeft= '+dLeft,73); */
 	}
/*    // absolute pos for oHtmlToMOve
 	else {
 		dTop  = _DDMgr.currDrag.dTopParentToBoundRef;
 		dLeft = _DDMgr.currDrag.dLeftParentToBoundRef;


		if (	_DDMgr.currDrag.oHtmlParentRef 
			== 	_DDMgr.currDrag.boundOHtmlRef ) {
			dTop = 0;
			dLeft = 0;
		}
		else {
			dTop  = ;
			dLeft = ;
		}

	}
*/
 } 	
 /* traceExec('AbsToRel dTop = '+dTop,73); */
/* traceExec('DDMM_AbsToRel end',73); */
return {top:dTop, left:dLeft};	 
}

rialto.widgetBehavior.$$DDMM_applyConstraintsMagneticsGrid = function (oSpecs,newPos,dTop,dLeft){
//========================================================
	 var nvTop = newPos.top;
	 var nvLeft = newPos.left;

	 var dLimLeft = dLimTop = 0;
	 if (oSpecs.movingLimits.rectLim)	{
		dLimLeft = oSpecs.movingLimits.rectLim.left;
		dLimTop  = oSpecs.movingLimits.rectLim.top;
	 }
	 if (oSpecs.movingLimits.orientation != 'v') {
		var nInterv = Math.round(	(	nvLeft
          						 	 -  dLeft - dLimLeft)
                  			     /   oSpecs.specs.magneticsGrid.widthCol
                  			    );
        nInterv = Math.min( (oSpecs.specs.magneticsGrid.nbVerticalLines-1),
        					nInterv);
        nvLeft =
        	(nInterv)
            * oSpecs.specs.magneticsGrid.widthCol
            + dLeft + dLimLeft;
	 }
	 if (oSpecs.movingLimits.orientation != 'h') {
		var nInterv = Math.round(	(	nvTop
          						 	 -  dTop - dLimTop)
                  			     /   oSpecs.specs.magneticsGrid.heightRow
                  			    );
        nInterv = Math.min( (oSpecs.specs.magneticsGrid.nbHorizontalLines-1),
        					nInterv);
        					
        nvTop =
        	(nInterv)
            * oSpecs.specs.magneticsGrid.heightRow
            + dTop + dLimTop;
	}

	newPos.top  = nvTop;
	newPos.left = nvLeft; 
}

rialto.widgetBehavior.$$DDMM_displayInfos = function(oMovingStyle,e,nvEventTopLeft) {
//========================================

	    if (_DDMgr.currDrag.oHtmlInfoFrame.isWithMovingInParentInfo)
		    var topLeft = 	(parseInt(oMovingStyle.top) + _DDMgr.currDrag.shiftAbsToRelTop) + ","  +
		    				(parseInt(oMovingStyle.left)+ _DDMgr.currDrag.shiftAbsToRelLeft) ;
		else 
		    var topLeft	= 	(parseInt(oMovingStyle.top) + _DDMgr.currDrag.shiftRelToAbsTop) + ","  +
		    				(parseInt(oMovingStyle.left) + _DDMgr.currDrag.shiftRelToAbsLeft);
    _DDMgr.currDrag.oHtmlInfoFrame.innerHTML = 
    	  topLeft
//		  parseInt(oMovingStyle.top) + ","
//	    + parseInt(oMovingStyle.left) 
	    + ' ( '
	    + _DDMgr.currDrag.totDeltaMoveTop 
	    + ','
	    + _DDMgr.currDrag.totDeltaMoveLeft
	    + ')';  

	_DDMgr.currDrag.oHtmlInfoFrame.style.top  = 
			nvEventTopLeft.top //e.clientY
			+ _DDMgr.currDrag.oHtmlInfoFrame.topShift;
	_DDMgr.currDrag.oHtmlInfoFrame.style.left = 
			nvEventTopLeft.left  //e.clientX
			+ _DDMgr.currDrag.oHtmlInfoFrame.leftShift;

}

rialto.widgetBehavior.$$DDMM_applyConstraintsLimits = function(oWithSpecs, newPos, dTop,dLeft) { 
//============================================
 var oHtmlToMove    = _DDMgr.currDrag.oHtmlToMove; 
 var posMovingOHtml = _DDMgr.currDrag.movingOHtml.style;
 var nvTop = newPos.top;
 var nvLeft = newPos.left;
 
 traceExec('nvTop= '+nvTop+' - dTop <? '+dTop +' oWithSpecs.movingLimits.rectLim.top= '+
 oWithSpecs.movingLimits.rectLim.top,2);


if (oWithSpecs.movingLimits.orientation == 'v') {
	nvLeft =   _DDMgr.currDrag.leftMovingDiv;
	/* traceExec('orient = v ; nvLeft = '+nvLeft,73); */
}
else
if (oWithSpecs.movingLimits.orientation == 'h')
	nvTop =   _DDMgr.currDrag.topMovingDiv;

 //-----  only verticals movements or 2D mvts
 if (	(oWithSpecs.movingLimits.orientation == 'v')
 	 || (oWithSpecs.movingLimits.orientation == '2D')){
	// a restreindre / existence autre curseur sur mm obj mobile
/* traceExec('parseInt(oWithSpecs.movingLimits.rectLim.top)= '+parseInt(oWithSpecs.movingLimits.rectLim.top),73); */	
    // contrainte top - bottom
    if (   (parseInt(nvTop) - dTop) 
    	<  parseInt(oWithSpecs.movingLimits.rectLim.top) ) {
/* traceExec('constraint 1',73); */
        nvTop = 
        	oWithSpecs.movingLimits.bCircular ?   (oWithSpecs.movingLimits.rectLim.bottom
                                                - parseInt(posMovingOHtml.height))
                                              : oWithSpecs.movingLimits.rectLim.top;
    	nvTop = parseInt(nvTop) + dTop;  
	}
                                                                           
	else  
//    if (     oWithSpecs.movingLimits.rectLim.bottom   // ssi limite vers  bas
//        &&  (
    if (   (   parseInt(nvTop) - dTop
             + parseInt(oHtmlToMove.offsetHeight) )
        >  parseInt(oWithSpecs.movingLimits.rectLim.bottom) ) {

/* traceExec('constraint 2',73); */
        nvTop = 
        	oWithSpecs.movingLimits.bCircular ?   oWithSpecs.movingLimits.rectLim.top
                                              :(   oWithSpecs.movingLimits.rectLim.bottom
                                                -  parseInt(oHtmlToMove.offsetHeight));
		nvTop = parseInt(nvTop) + dTop;                                                
	}
                                                                            
 }   // 'v'

 //-----  only horizontals movements or 2D mvts
 if (	(oWithSpecs.movingLimits.orientation == 'h')
 	 || (oWithSpecs.movingLimits.orientation == '2D')){
	// a restreindre / existence autre curseur sur mm obj mobile
    

    // contrainte left - right
    if (   (  parseInt(nvLeft) 
            - dLeft) 
        <  parseInt(oWithSpecs.movingLimits.rectLim.left)){
/* traceExec('constraint 3',73); */
         nvLeft = oWithSpecs.movingLimits.bCircular ? (  parseInt(oWithSpecs.movingLimits.rectLim.right)
                                                                 - parseInt(posMovingOHtml.width))
                                                             : parseInt(oWithSpecs.movingLimits.rectLim.left);
    	nvLeft = parseInt(nvLeft) + dLeft;                                                
    }
//    else
//    if (     oWithSpecs.movingLimits.rectLim.right            // ssi limite droite
//        &&   (
//              (   (parseInt(nvLeft) - dLeft) ...
    else
    if (   (   (parseInt(nvLeft) - dLeft)
    			+ parseInt(oHtmlToMove.offsetWidth) )
         > parseInt(oWithSpecs.movingLimits.rectLim.right)) {
/* traceExec('constraint 4',73); */
        nvLeft = 
        		oWithSpecs.movingLimits.bCircular ?  parseInt(oWithSpecs.movingLimits.rectLim.left)
                                                  : (  parseInt(oWithSpecs.movingLimits.rectLim.right)
                                                     - parseInt(oHtmlToMove.offsetWidth));
		nvLeft = parseInt(nvLeft) + dLeft;                                                

    }
 }  // 'h' or '2D'

  newPos.top  = nvTop;
  newPos.left = nvLeft; 
                  
}


rialto.widgetBehavior.$$DDMM_applyConstraintTargets = function (oWithSpecs) {
//=================================================
    if (!
    	_DDMgr.flyOverTarget(oWithSpecs)
    	)
    	_DDMgr.flyOverTarget(oWithSpecs, unauthorized=true); 
	/* traceExec('_DDMgr.currDrag.cibleOk= '+_DDMgr.currDrag.cibleOk,79); */
}
                          


rialto.widgetBehavior.$$DDMM_CallBackSynchro = function (oWithSpecs) {
//==========================================
    var   oMovingStyle = _DDMgr.currDrag.movingOHtml.style;
//alert('_DDMgr.currDrag.prevTop= '+_DDMgr.currDrag.prevTop);
    //--- since last mouse move
    var deltaTop =    parseInt(oMovingStyle.top)
                         - parseInt(_DDMgr.currDrag.prevTop) ;
    var deltaLeft =   parseInt(oMovingStyle.left)
                         - parseInt(_DDMgr.currDrag.prevLeft);

    //--- save present positions
    _DDMgr.currDrag.prevTop  = parseInt(oMovingStyle.top);
    _DDMgr.currDrag.prevLeft = parseInt(oMovingStyle.left);


	//--- callback
    oWithSpecs.synchro(   {top: _DDMgr.currDrag.totDeltaMoveTop, left: _DDMgr.currDrag.totDeltaMoveLeft}  // total
                      	, {top: deltaTop,    left: deltaLeft}     // since last mouse move
                      	, {}                                      //initial position on mouse down ?other info?
                      );
}     


rialto.widgetBehavior.DragAndDropMouseUpHandler = function (e){
//---------------------------------------------
/* traceExec('Mup  -------------------------------',1); */
	 if (!e) var e = window.event;
   
   // moving object
    if (	_DDMgr.currDrag 
    	&& _DDMgr.currDrag.movingOHtml){ // ? condit? to revise

       // IE model
       if ( this.releaseCapture){
         if (   (!_DDMgr.currDrag.oThis.specs.modCurs.avantDD)
            && (_DDMgr.currDrag.oThis.specs.modCurs.auClic)) {
              this.style.cursor = 'default';
         }
         this.releaseCapture();
       }

       //  W3C Moz model
       else{
         if (_DDMgr.currDrag.ghost)
           _DDMgr.currDrag.movingOHtml.style.cursor = 'default';
         else
           _DDMgr.currDrag.oSource.style.cursor = 'default';
       }
       // free ReDim 
       //if (oHtml.oCiu['ReSize']) oHtml.oCiu['ReSize'].reSize = oHtml.oCiu['ReSize'].svgReSize;


       var  oHtml = _DDMgr.currDrag.movingOHtml;

		// unlock DD
		_DDMgr.currDrag.oSource.behavior['DD'].isRunning = false;

       var oThis = _DDMgr.currDrag.oThis;
       
       // compute delta 
       //--- calcul des deplacts depuis le Mouse Down et deplact effectif si besoin
        // deplacement effectif a realiser
        if (_DDMgr.currDrag.bMUpAction){
			/* traceExec('Mup bMUpAction==true',1); */
			
            // verification de la position /cibles autorisees 
            // ou l'absence de cible definie
            /* traceExec('DD Mup _DDMgr.currDrag.cibleOk= '+_DDMgr.currDrag.cibleOk,77); */
            if (   (!oThis.specs.dropTargets)
                || (_DDMgr.currDrag.cibleOk)) {
			   /* traceExec('(!oThis.specs.dropTargets)|| (_DDMgr.currDrag.cibleOk)',77); */
			   
               // deplact indirect
               if (_DDMgr.currDrag.oHtmlToMove != _DDMgr.currDrag.movingOHtml) {
                    // deplacement effectif de l'objet a deplacer
			        if (_DDMgr.currDrag.mvtEffectif) {
						_DDMgr.currDrag.oHtmlToMove.style.top = //prevoir le cas 0 (pas de top defini)
//	                                     parseInt(_rum.$getStyle(_DDMgr.currDrag.oHtmlToMove,'top'))
										_DDMgr.currDrag.oHtmlToMove.offsetTop
	                                   + _DDMgr.currDrag.totDeltaMoveTop
	                                   + shiftTopForIcon;
						_DDMgr.currDrag.oHtmlToMove.style.left = 
										_DDMgr.currDrag.oHtmlToMove.offsetLeft
	                                   + _DDMgr.currDrag.totDeltaMoveLeft
	                                   + shiftLeftForIcon;
	                    traceExec('Mup indirect move top f= '+_DDMgr.currDrag.movingOHtml.style.top
	                               + ' oad= '+_DDMgr.currDrag.oHtmlToMove.style.top,5);
					}
               }
				else {/* traceExec('Mup direct move',77); */
               		_DDMgr.currDrag.oHtmlToMove.style.zIndex 
               			= _DDMgr.currDrag.svgZIndex;  
               		//alert('_DDMgr.currDrag.svgZIndex= '+_DDMgr.currDrag.svgZIndex); 
               }

                            
               if (oThis.synchroDDMup) {
                    
                    oThis.synchroDDMup( {// deplact total   depuis Md
			                    			 top  : _DDMgr.currDrag.totDeltaMoveTop //totDeltaTop
			                    			,left : _DDMgr.currDrag.totDeltaMoveLeft //totDeltaLeft
			                    		}                 
                                    	,{}                                                     // positions initiales au Md
                                      );
               }
            }
            // with targets : direct move and drop outer of authorized targets
            else {
				traceExec('oThis.specs.dropTargets = '+ oThis.specs.dropTargets
				+' _DDMgr.currDrag.cibleOk= '+_DDMgr.currDrag.cibleOk,77);
				// DragAndDrop direct without ghost, 
				// with targets but target over KO
				if (    _DDMgr.currDrag.oHtmlToMove
					==  _DDMgr.currDrag.movingOHtml) {
                	/* traceExec(' cibles mais cible survol?e KO -> retour pos initiale',1); */
                	// old parent and positions restored
					/*                            	
						if (_DDMgr.currDrag.nextSiblOHtmlToMove)
	                                    _DDMgr.currDrag.parentOHtmlToMove.insertBefore(
	                                    			_DDMgr.currDrag.movingOHtml
	                                    			,_DDMgr.currDrag.nextSiblOHtmlToMove);
	                    else
	                            		_DDMgr.currDrag.parentOHtmlToMove.appendChild(
	                            					_DDMgr.currDrag.movingOHtml);
					*/   
			traceExec('places initiale topI = '+ _DDMgr.currDrag.initialTop
			+' leftI= '+_DDMgr.currDrag.initialLeft,79);                        		
         			_DDMgr.currDrag.movingOHtml.style.top = 
         				_DDMgr.currDrag.initialTop;

         			_DDMgr.currDrag.movingOHtml.style.left = 
         				_DDMgr.currDrag.initialLeft;

                }
			}
                        
        }       

       // mask ghost
       if (_DDMgr.currDrag.ghost)
		   // _DDMgr.currDrag.movingOHtml.style.visibility = 'hidden';
	       _DDMgr.currDrag.movingOHtml.style.display = 'none';
	
       traceExec('Mup objetEnDeplact.top = '+_DDMgr.currDrag.movingOHtml.style.top
                   + ' oHtmlToMov.top = '+_DDMgr.currDrag.oHtmlToMove.style.top,1);

		if (_DDMgr.currDrag.oThis.movingLimits.isWithLimitsDisplayed)
//			_DDMgr.currDrag.boundOHtmlRef.removeChild(_DDMgr.currDrag.oHtmlLimitsRect);
			document.body.removeChild(_DDMgr.currDrag.oHtmlLimitsRect);
		if (_DDMgr.currDrag.oHtmlInfoFrame)
			document.body.removeChild(_DDMgr.currDrag.oHtmlInfoFrame);

       // declencht de traitements cod?s dans l'objet ayant re?u le comportement DD

        // mvt effectif
        if (_DDMgr.currDrag.mvtEffectif) {
        	 /* traceExec('Mup real movement',1); */
	         if (oThis.afterDD){
	        
	           oThis.afterDD( _DDMgr.currDrag.totDeltaMoveTop  //totDeltaTop
	                         ,_DDMgr.currDrag.totDeltaMoveLeft	//totDeltaLeft
	                         ,(_DDMgr.currDrag.cibleOk ? {  oCible:     _DDMgr.currDrag.target
	                                                       ,topInCible: _DDMgr.currDrag.topInTarget
	                                                       ,leftInCible:_DDMgr.currDrag.leftInTarget
	                                              		 }
	                                            	   : null)
	                        );
	         }
        
			 _DDMgr.drop();
			 		 
	         traceExec('Mup after drop objetEnDeplact.top = '+_DDMgr.currDrag.movingOHtml.style.top
                   + ' oHtmlToMov.top = '+_DDMgr.currDrag.oHtmlToMove.style.top,1);
	         /* traceExec('Mup oHtmlToMove.position = '+_DDMgr.currDrag.oHtmlToMove.style.position,1); */
/*           
					_DDMgr.drop();
		                     
		             if (_DDMgr.currDrag.cibleOk) {
		                // traceExec('Mup cibleOK '+_DDMgr.currDrag.lastTarget.DDOuter,5); 
		                if (_DDMgr.currDrag.lastTarget.DDOuter){
		                   _DDMgr.currDrag.lastTarget.DDOuter(
		                                  {    oHtml: _DDMgr.currDrag.objADeplacer
		                                     , topAbs : _DDMgr.currDrag.topObjEnDeplact
		                                     , leftAbs: _DDMgr.currDrag.leftObjEnDeplact
		                                   });
			     	       // traceExec('Mup ddouter',5); 
		                }
		                if (_DDMgr.currDrag.target.receiveAfterDrop) {
			               _DDMgr.currDrag.target.receiveAfterDrop( {   oHtml: _DDMgr.currDrag.oHtmlToMove
			                     										, top:_DDMgr.currDrag.topInTarget
		    	                 										, left:_DDMgr.currDrag.leftInTarget
		        	             									  }
		            	         									 );
		                }
		            	else { // default; to revise
		            	// traceExec('place in Target',73); 
		            	   //var oHtmlTarg = _DDMgr.currDrag.target;
		                                _DDMgr.currDrag.oHtmlToMove.style.position  = 'absolute';
		                                _DDMgr.currDrag.oHtmlToMove.style.top 		= _DDMgr.currDrag.topInTarget;
		                                _DDMgr.currDrag.oHtmlToMove.style.left 	    = _DDMgr.currDrag.leftInTarget;            	         
		                                _DDMgr.currDrag.target.appendChild(_DDMgr.currDrag.oHtmlToMove);
		            	}
		            	         
		             }
*/
	    }
        // seult un clic realise : pas de mvt
        else{
    	 	/* traceExec('Mup only click without move',1); */
           if (oThis.afterClic)
              oThis.afterClic();
        }
               
       // deselection 
       if (_DDMgr.currDrag.maskSelect) {
		  /* traceExec('_DDMgr.currDrag.maskSelect.parentNode.tagName= '+_DDMgr.currDrag.maskSelect.parentNode.tagName,22); */
          _DDMgr.currDrag.maskSelect.parentNode.removeChild(_DDMgr.currDrag.maskSelect);
		  /* traceExec('Mup remove select mark',22); */
       }
                  
                  
       _DDMgr.currDrag = null;
	   /* traceExec('Mup _DDMgr.currDrag = '+_DDMgr.currDrag,73); */
	   
       stopEvent(e);
        }
}
  